package com.atguigu.gmall.product.client.impl;

import com.alibaba.fastjson.JSONObject;
import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.product.*;
import com.atguigu.gmall.product.client.ProductFeignClient;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @author Fxz
 * @version 1.0
 * @date 2022-02-08 9:55
 */
@Slf4j
@Component
public class ProductDegradeFeignClient implements FallbackFactory<ProductFeignClient> {

	private static void logInfo(Throwable throwable) {
		log.info("方法调用失败:{}", throwable.getMessage());
	}

	@Override
	public ProductFeignClient create(Throwable throwable) {
		ProductDegradeFeignClient.logInfo(throwable);
		return new ProductFeignClient() {
			@Override
			public SkuInfo getSkuInfo(Long skuId) {
				return null;
			}

			@Override
			public BaseCategoryView getCategoryView(Long category3Id) {
				return null;
			}

			@Override
			public BigDecimal getSkuPrice(Long skuId) {
				return null;
			}

			@Override
			public List<SpuSaleAttr> getSpuSaleAttrListCheckBySku(Long skuId, Long spuId) {
				return null;
			}

			@Override
			public Map getSkuValueIdsMap(Long spuId) {
				return null;
			}

			@Override
			public Result<List<JSONObject>> getBaseCategoryList() {
				return null;
			}

			@Override
			public BaseTrademark getTrademark(Long tmId) {
				return null;
			}

			@Override
			public List<BaseAttrInfo> getAttrList(Long skuId) {
				return null;
			}
		};
	}

}
